package com.ht.impl.shape;

import com.ht.impl.drawtool.ArcTool;
import com.mxgraph.canvas.mxGraphics2DCanvas;
import com.mxgraph.shape.mxBasicShape;
import com.mxgraph.view.mxCellState;

import java.awt.*;
import java.awt.geom.Arc2D;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2010-6-18
 */
public class htArcShape extends mxBasicShape {
    /**
     *
     */
    public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state) {//todo: not finished!
        Rectangle temp = state.getRectangle();
        int angle = Integer.parseInt(state.getStyle().get(ArcTool.START_ANGLE).toString());
        int position = Integer.parseInt(state.getStyle().get(ArcTool.RECT_POSITION).toString());
        switch (position) {
            case ArcTool.POSITION_LEFT_TOP:
                return new Arc2D.Double(temp.x, temp.y, 2 * temp.width, 2 * temp.height, angle, 90, Arc2D.OPEN);
            case ArcTool.POSITION_LEFT_BOTTOM:
                return new Arc2D.Double(temp.x, temp.y - temp.height, 2 * temp.width, 2 * temp.height, angle, 90, Arc2D.OPEN);
            case ArcTool.POSITION_RIGHT_TOP:
                return new Arc2D.Double(temp.x - temp.width, temp.y, 2 * temp.width, 2 * temp.height, angle, 90, Arc2D.OPEN);
            case ArcTool.POSITION_RIGHT_BOTTOM:
                return new Arc2D.Double(temp.x - temp.width, temp.y - temp.height, 2 * temp.width, 2 * temp.height, angle, 90, Arc2D.OPEN);
        }
        return null;
    }
}
